<?php

namespace App\Admin\Controllers;

use App;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;
use App\Models\BarCode;
use BarCodeService;

class BarCodeController extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('backend.bar_code.title.list'));
            $content->body($this->grid());
        });
    }

    /**
     * Edit interface.
     *
     * @param $id
     * @return Content
     */
    public function edit($id)
    {
        return Admin::content(function (Content $content) use ($id) {
            $content->header(trans('backend.bar_code.title.edit'));
            $content->body($this->form()->edit($id));
        });
    }

    /**
     * Create interface.
     *
     * @return Content
     */
    public function create()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('backend.bar_code.title.add'));
            $content->body($this->form());
        });
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Admin::grid(BarCode::class, function (Grid $grid) {
            $grid->id(trans('backend.bar_code.column.id'));
			$grid->bar_code_id(trans('backend.bar_code.column.bar_code_id'));
			$grid->protein_nutritrion_level(trans('backend.bar_code.column.protein_nutritrion_level'));
			$grid->carbo_nutritrion_level(trans('backend.bar_code.column.carbo_nutritrion_level'));
			$grid->sodium_nutritrion_level(trans('backend.bar_code.column.sodium_nutritrion_level'));
			$grid->fat_nutritrion_level(trans('backend.bar_code.column.fat_nutritrion_level'));
			
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Admin::form(BarCode::class, function (Form $form) {
            $form->text('id',trans('backend.bar_code.column.id'));
			$form->text('bar_code_id',trans('backend.bar_code.column.bar_code_id'));
			$form->text('protein_nutritrion_level',trans('backend.bar_code.column.protein_nutritrion_level'));
			$form->text('carbo_nutritrion_level',trans('backend.bar_code.column.carbo_nutritrion_level'));
			$form->text('sodium_nutritrion_level',trans('backend.bar_code.column.sodium_nutritrion_level'));
			$form->text('fat_nutritrion_level',trans('backend.bar_code.column.fat_nutritrion_level'));
			
        });
    }
}
